.\"
.\" Copyright (C) 1994-2021 Altair Engineering, Inc.
.\" For more information, contact Altair at www.altair.com.
.\"
.\" This file is part of both the OpenPBS software ("OpenPBS")
.\" and the PBS Professional ("PBS Pro") software.
.\"
.\" Open Source License Information:
.\"
.\" OpenPBS is free software. You can redistribute it and/or modify it under
.\" the terms of the GNU Affero General Public License as published by the
.\" Free Software Foundation, either version 3 of the License, or (at your
.\" option) any later version.
.\"
.\" OpenPBS is distributed in the hope that it will be useful, but WITHOUT
.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
.\" FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
.\" License for more details.
.\"
.\" You should have received a copy of the GNU Affero General Public License
.\" along with this program.  If not, see <http://www.gnu.org/licenses/>.
.\"
.\" Commercial License Information:
.\"
.\" PBS Pro is commercially licensed software that shares a common core with
.\" the OpenPBS software.  For a copy of the commercial license terms and
.\" conditions, go to: (http://www.pbspro.com/agreement.html) or contact the
.\" Altair Legal Department.
.\"
.\" Altair's dual-license business model allows companies, individuals, and
.\" organizations to create proprietary derivative works of OpenPBS and
.\" distribute them - whether embedded or bundled with other software -
.\" under a commercial license agreement.
.\"
.\" Use of Altair's trademarks, including but not limited to "PBS™",
.\" "OpenPBS®", "PBS Professional®", and "PBS Pro™" and Altair's logos is
.\" subject to Altair's trademark licensing policies.
.\"
.TH pbs_selstat 3B "15 November 2019" Local "PBS Professional"
.SH NAME
.B pbs_selstat 
\- get status of selected PBS batch jobs
.SH SYNOPSIS
#include <pbs_error.h>
.br
#include <pbs_ifl.h>
.sp
.nf
.B struct batch_status *
.B pbs_selstat(int connect, struct attropl *criteria_list, 
.B \ \ \ \ \ \ \ \ \ \ \ \ struct attrl *output_attribs, char *extend)
.fi

.SH DESCRIPTION
Issues a batch request to get the status of jobs which meet the specified criteria.  

Generates a 
.I Select Status 
(51) batch request and sends it to the server over the connection specified by 
.I connect.

Returns a list of 
.I batch_status 
structures for jobs that meet the selection criteria.

This function is a combination of 
.B pbs_selectjob() 
and 
.B pbs_statjob().  

By default this gives status for all jobs for which you are authorized
to query status.  You can filter the results by specifying selection
criteria.

.SH ARGUMENTS
.IP connect 8
Return value of 
.B pbs_connect().  
Specifies connection handle over which to send batch request to server.

.IP criteria_list 8
Pointer to a list of selection criteria, which are attributes and
resources with required values.  If this list is null, you are not
filtering your results via selection criteria.  Each attribute or
resource is described in an 
.I attropl 
structure, defined in pbs_ifl.h
as:
.nf
struct attropl {
        struct attropl *next;
        char           *name;
        char           *resource;
        char           *value;
        enum batch_op  op;
};
.fi
If 
.I criteria_list 
itself is null, you are not using attributes or resources as selection criteria.

.IP output_attribs 8
Pointer to a list of attributes to return.  If this list is null, all
attributes are returned.  Each attribute is described in an 
.I attrl
structure, defined in pbs_ifl.h as:
.nf
struct attrl {
        char         *name;
        char         *resource;
        char         *value;
        struct attrl *next;
};
.fi
.IP extend 8
Character string where you can specify limits or extensions of your selection.
.LP
.B Members of attropl Structure
.br
.IP next 8
Points to next attribute in list.  A null pointer terminates the list.

.IP name 8
Points to a string containing the name of the attribute.  

.IP resource 8
Points to a string containing the name of a resource.  Used only when
the specified attribute contains resource information.  Otherwise,
.I resource
should be a null pointer.

.IP value 8
Points to a string containing the value of the attribute or resource.
For parameterized limit attributes, this string contains all
parameters for the attribute.

.IP op 8
Specifies the test to be applied to the attribute or resource.  The
operators are 
.I EQ, NE, GE, GT, LE, LT.
.LP 

.B Members of attrl Structure
.br
.IP name 8
Points to a string containing the name of the attribute.  

.IP resource 8
Points to a string containing the name of a resource.  Used only when
the specified attribute contains resource information.  Otherwise, 
.I resource 
should be a null pointer.

.IP value 8
Points to a string containing the value of the attribute or resource.  Should always be null.

.IP next 8
Points to next attribute in list.  A null pointer terminates the list.

.SH QUERYING STATES
You can select jobs in more than one state using a single request, by
listing all states you want returned.  For example, to get jobs in
.I Held 
and 
.I Waiting 
states:
.RS 3
Fill in 
.I criteria_list->name 
with "job_state"
.br
Fill in 
.I criteria_list->value 
with "HW" for 
.I Held 
and 
.I Waiting
.RE
.SH EXTENDING YOUR QUERY
You can use the following characters in the 
.I extend 
parameter:
.IP "T, t" 8
Extends query to include subjobs.  Job arrays are not included.
.IP x 8
Extends query to include finished and moved jobs.
.LP

.B Querying Finished and Moved Jobs
.br
To get information on finished or moved jobs, as well as current jobs,
add an 'x' character to the 
.I extend 
parameter (set one character to be the 'x' character).  For example:
.nf
   pbs_selstat ( ..., ..., <extend characters>) ...
.fi
To get information on finished jobs only:
.RS 3
Add the "x" character to the 
.I extend 
parameter
.br
Fill in 
.I criteria_list->name 
with "ATTR_state"
.br
Fill in 
.I criteria_list->value 
with "FM" for 
.I Finished 
and 
.I Moved
.RE
For example:
.nf
   criteria_list->name = ATTR_state;
   criteria_list->value = "FM";
   criteria_list->op = EQ;
   pbs_selstat ( ..., criteria_list, ..., extend) ...
.fi
Subjobs are not considered finished until the parent array job is finished.

.B Querying Job Arrays and Subjobs
.br
To query only job arrays (not jobs or subjobs):
.RS 3
Fill in 
.I criteria_list->name 
with "array"
.br
Fill in 
.I criteria_list->value 
with "True"
.RE

To query only job arrays and subjobs (not jobs):
.RS 3
Fill in 
.I criteria_list->name 
with "array"
.br
Fill in 
.I criteria_list->value 
with "True"
.br
Add the "T" or "t" character to the 
.I extend 
parameter
.RE
To query only jobs and subjobs (not job arrays), add the "T" or "t" character to the 
.I extend 
parameter.

.SH RETURN VALUE
Returns a pointer to a list of 
.I batch_status 
structures for jobs that meet the selection criteria.  If no jobs meet
the criteria or can be queried for status, returns the null pointer.

If an error occurred, the routine returns a null pointer, and the
error number is available in the global integer 
.I pbs_errno.

.B The batch_status Structure
.br
The 
.I batch_status 
structure is defined in pbs_ifl.h as
.nf
struct batch_status {
        struct batch_status *next;
        char                *name;
        struct attrl        *attribs;
        char                *text;
}
.fi

.SH CLEANUP
You must free the list of 
.I batch_status 
structures when no longer needed, by calling 
.B pbs_statfree().

.SH SEE ALSO
qselect(1B), qstat(1B), pbs_connect(3B), pbs_selectjob(3B), pbs_statjob(3B)

